package com.io.nio;

import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

/**
 * 更好的文件复制
 * 
 * @author Administrator
 * 
 */
public class ChannelCopyBetter {

	private static final int BSIZE = 1024;

	public static void main(String[] args) throws IOException {
		FileChannel in = new FileInputStream("c:/vcredist_x86.log")
				.getChannel(), out = new FileOutputStream(
				"c:/vcredist_x862.log").getChannel();
		ByteBuffer buffer = ByteBuffer.allocate(BSIZE);
		in.transferTo(0, in.size(), out);
		// 或者
		//out.transferFrom(in, 0, in.size());
	}

}
